// water refraction from RasterTeks DirectX11 Terrain Tutorial 16: Small Body Water
// website link: http://rastertek.com/tertut16.html
// date referenced February 15th 2013

#ifndef DX11WATER_H
#define DX11WATER_H

#include "DX11VertexData.h"
#include "ConstantBuffer.h"
#include "ReflectionBuffer.h"

#include <vector>
#include <D3D11.h>
#include <D3DX10math.h>

class DX11Water
{
public:
	DX11Water();
	~DX11Water();
	bool Initialize(float size, float height);

	void Draw();
	void Update();
	void GetPosition(D3DXVECTOR3& pos);

	void SetRefractionTexture(ID3D11ShaderResourceView* tex);
	void SetReflectionTexture(ID3D11ShaderResourceView* tex);

	void SetColour(const D3DXVECTOR4& colour);

private:
	void DrawWater();

private:
	int m_numOfIndices;

	D3DXVECTOR3 m_position;

	D3DXMATRIX m_world;

	std::vector<VertexData> m_vertexData;
	std::vector<DWORD> m_indices;

	ID3D11Buffer* m_vertexBuffer;
	ID3D11Buffer* m_indexBuffer;
	D3D11_BUFFER_DESC m_bd;
	D3D11_SUBRESOURCE_DATA m_data;
	ID3D11Buffer* m_pConstantBuffer;

	ConstantBuffer m_cb;

	ID3D11SamplerState* m_pTextureSamplerState;
	ID3D11ShaderResourceView* m_pRefractionTextureResource;
	ID3D11ShaderResourceView* m_pReflectionTextureResource;

	D3DXVECTOR2 m_texturePosition;

	ID3D11Buffer* m_pReflectionBuffer;
	ReflectionBuffer m_rb;

	D3DXVECTOR4 m_colour;
};

#endif //DX11WATER_H2